package database

import (
	"gorm.io/gorm"
	"hxy/repo/model"
	"time"
)

func DockerTaskCreate(builder *model.DockerImageBuilder) *gorm.DB {
	builder.Begin_time = time.Now()
	return Db.Create(&builder)
}
func DockerTaskUpdateStatus(builder model.DockerImageBuilder) *gorm.DB {
	if builder.Status == model.DockerFinished {
		Db.Model(&builder).Update("end_time", time.Now())
	}
	return Db.Model(&builder).Update("status", builder.Status)
}
func DockerTaskByCommitHash(hash string) []model.DockerImageBuilder {
	var list []model.DockerImageBuilder
	Db.Where("git_hash = ?", hash).Find(&list)
	return list
}
